import {GiftedChat} from 'react-native-gifted-chat';
import {clone} from '../../../utils/utils';

const defaultState = {
	messages: [
        {
        	_id: 998,
        	text: 'Hello developer1',
        	createdAt: new Date(),
        	user: {
            	_id: 2,
            	name: 'React Native',
            	avatar: require('../../../assets/img/userIcon-test.jpg'),
          	},
        },
    ],
};

export default {

	namespace: 'group',
	
	state: {...defaultState},
	
	reducers: {
		appendMessage(state, {payload}) {
			let stateClone= clone(state);
			if(payload) {
				stateClone.messages = GiftedChat.append(stateClone.messages, payload);
			} 
			return stateClone;
		}
	},
	
	effects: {
		
	},
	
}